package com.woniu.day8.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.woniu.day8.pojo.Records;
import com.woniu.day8.pojo.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RecordsMapper extends BaseMapper<Records> {
    @Select("SELECT r.id,p.name AS type_name,r.up_num,r.down_num,h.numbers AS house_name,r.up_time,r.on_time,r.check_time,r.meter,r.remarks\n" +
            "FROM records r \n" +
            "JOIN property_type p ON r.type_id = p.id\n" +
            "JOIN house h ON h.id = r.house_id\n" +
            "JOIN building b ON h.building_id = b.id ${ew.customSqlSegment}")
    @Results(id = "recordsMap",value = {
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "type_name",property = "typeName"),
            @Result(column = "up_num",property = "upNum"),
            @Result(column = "down_num",property = "downNum"),
            @Result(column = "house_name",property = "houseName"),
            @Result(column = "up_time",property = "upTime"),
           @Result(column = "on_time",property = "onTime"),
            @Result(column = "check_time",property = "checkTime"),
            @Result(column = "meter",property = "meter"),
            @Result(column = "remarks",property = "remarks")
    })
    List<Records> selectRecords(IPage<Records> page, @Param("ew") QueryWrapper<Records> wrapper);
}
